Amazon CloudFront에서 특정 국가에 대한 접근 차단해 보기

Amazon CloudFront에서 특정 국가에 대한 접근 차단해 보기

Amazon CloudFront에서 특정 국가에 대한 접근을 차단해 보는 방법을 정리해 봤습니다.
Clock Icon2024.09.19

안녕하세요 클래스메소드 김재욱(Kim Jaewook) 입니다. 이번에는 Amazon CloudFront에서 특정 국가에 대한 접근을 차단해 보는 방법을 정리해 봤습니다.

이번 블로그에서는 Amazon S3와 Amazon CloudFront를 연동하여 OAI로 접근할 때 특정 국가에서의 접근을 차단하는 방법을 안내합니다. Amazon S3를 생성하고 Amazon CloudFront와 연동하는 방법에 대해서는 아래 블로그를 참고해 주세요.

https://dev.classmethod.jp/articles/restrict-s3-access-through-cloudfront-oai/

접속 테스트

jw-clftest-blg-1

Amazon S3에는 테스트용 이미지를 업로드한 상태입니다.

Amazon S3와 Amazon CloudFront 연동이 끝났다면, Amazon CloudFront의 도메인 이름을 이용해서 접근을 시도합니다.

접근을 위한 도메인은 다음과 같습니다.

  • xxxxxxxxx.cloudfront.net/test-image.jpeg

jw-clftest-blg-2

도메인으로 접속해 보면, 성공적으로 테스트용 이미지가 출력됩니다.

국가 차단 설정

이제 특정 국가에 대한 접속을 차단해 보도록 하겠습니다.

jw-clftest-blg-3

생성한 Amazon CloudFront 배포를 클릭하고「보안」→「CloudFront geographic restrictions」→「Edit」를 클릭합니다.

jw-clftest-blg-4

「Restriction type」에는 세 가지 타입이 존재합니다.

  • No restrictions : 차단 없음
  • Allow list : 접근을 허용할 국가 리스트
  • Block list : 접근을 차단할 국가 리스트

이번에는 특정 국가에 대한 접속을 차단할 생각이므로 Block list에서 차단할 국가를 선택하고, 변경 사항을 저장합니다.

국가 차단 후 접속 테스트

차단 설정을 완료했다면 동일한 도메인으로 접속을 시도해 봅시다.

  • xxxxxxxxx.cloudfront.net/test-image.jpeg

jw-clftest-blg-5

이번에는 테스트용 이미지가 출력되는 대신에 403 ERROR 메시지가 출력되는 것을 확인할 수 있습니다.

The Amazon CloudFront distribution is configured to block access from your country. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

출력된 메시지를 살펴보면, Amazon CloudFront 배포에서 해당 국가에 대한 액세스를 차단했거나 트래픽이 많아 오류가 발생했을 가능성이 있다고 설명하고 있습니다.

이러한 기능을 통해 특정 국가에서의 악의적인 접근을 차단할 수 있습니다. 보다 상세한 내용은 아래 AWS 공식 문서를 참고해 주세요.

https://docs.aws.amazon.com/ko_kr/AmazonCloudFront/latest/DeveloperGuide/georestrictions.html#georestrictions-cloudfront

본 블로그 게시글을 읽고 궁금한 사항이 있으신 분들은 jaewookkim533@yahoo.com로 보내주시면 감사하겠습니다.

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.